home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / basic / ltest1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1014 b   |  58 lines

  1. #include <LEDA/basic.h>
  2. #include <LEDA/list.h>
  3.  
  4. typedef int* int_ptr;
  5.  
  6.  
  7. int main () 
  8. {
  9.   list<int_ptr>     L;
  10.   list<int_ptr>     L1;
  11.  
  12.   int i;
  13.   int_ptr p;
  14.  
  15.   int N = read_int("Number of list entries: "); 
  16.  
  17.   float T = used_time();
  18.  
  19.   cout << "allocating    ";
  20.   cout.flush();
  21.   for (i = 0; i < N; i++) L.append((int_ptr)random(1,10000));
  22.   cout << string("  %5.3f sec",used_time(T));
  23.   newline;
  24.  
  25.  
  26.   cout << "reversing     ";
  27.   cout.flush();
  28.   while (!L.empty()) L1.push(L.pop());
  29.   cout << string("  %5.3f sec",used_time(T));
  30.   newline;
  31.  
  32.   cout << "assignment    ";
  33.   cout.flush();
  34.   L = L1;
  35.   cout << string("  %5.3f sec",used_time(T));
  36.   newline;
  37.  
  38.   cout << "sorting(int)  ";
  39.   cout.flush();
  40.   L.sort();
  41.   cout << string("  %5.3f sec",used_time(T));
  42.   newline;
  43.  
  44.   cout << "iteration     ";
  45.   cout.flush();
  46.   forall(p,L) {}
  47.   cout << string("  %5.3f sec",used_time(T));
  48.   newline;
  49.  
  50.   cout << "clear         ";
  51.   cout.flush();
  52.   L.clear();
  53.   cout << string("  %5.3f sec",used_time(T));
  54.   newline;
  55.  
  56.   return 0;
  57. }
  58.